package org.ourgrid.acceptance.util.discoveryservice;

import java.util.List;

import org.easymock.classextension.EasyMock;
import org.ourgrid.acceptance.util.DiscoveryServiceAcceptanceUtil;
import org.ourgrid.common.interfaces.CommunityStatusProvider;
import org.ourgrid.common.interfaces.CommunityStatusProviderClient;
import org.ourgrid.discoveryservice.DiscoveryServiceComponent;

import br.edu.ufcg.lsd.commune.container.ContainerContext;
import br.edu.ufcg.lsd.commune.container.ObjectDeployment;
import br.edu.ufcg.lsd.commune.identification.DeploymentID;
import br.edu.ufcg.lsd.commune.test.AcceptanceTestUtil;

public class Req_509_Util extends DiscoveryServiceAcceptanceUtil {

	public Req_509_Util(ContainerContext context) {
		super(context);
	}
	
	public void getPeerStatusProviders(DiscoveryServiceComponent component, 
			List<String> psps, DeploymentID senderID) {
		
		CommunityStatusProvider communityStatusProvider = getCommunityStatusProviders(component);
		ObjectDeployment dsObjectDeployment = getCommunityStatusProvidersObjectDeployment(component);
		
		CommunityStatusProviderClient communityStatusProviderClient = 
			EasyMock.createMock(CommunityStatusProviderClient.class);
		
		CommunityStatusProviderClient client = EasyMock.createMock(CommunityStatusProviderClient.class);
		
		AcceptanceTestUtil.publishTestObject(component, senderID, client, CommunityStatusProviderClient.class);
		AcceptanceTestUtil.setExecutionContext(component, dsObjectDeployment, senderID);
		
//		List<DeploymentID> pspIDs = new ArrayList<DeploymentID>();
//		if (psps != null) {
//			for (String testStub : psps) {
//				AcceptanceTestUtil.publishTestObject(component, testStub.getDeploymentID(), testStub.getObject(),
//						PeerStatusProvider.class);
//				pspIDs.add(testStub.getDeploymentID());
//			}
//		}
		
		//recording mock behavior
		communityStatusProviderClient.hereIsStatusProviderList(psps);
		
		EasyMock.replay(communityStatusProviderClient);

		communityStatusProvider.getPeerStatusProviders(communityStatusProviderClient);
		
		EasyMock.verify(communityStatusProviderClient);
	}
}
